Medium thickness plates in energy, chemical industry, marine engineering and other fields often need to be formed by multilayer multipass welding method. For ensuring the quality of welding products, it is of great significance to recognize a trajectory position to be welded by visual methods and adjust relative positions between a welding gun and a workpiece, so as to compensate an offset (caused by dimensional deviation, positioning errors of tools, welding thermal deformation and other factors) between an actual weld pass trajectory and a movement trajectory predetermined by an motion actuator.